//
//  BRODListView.m
//  Kexu
//
//  Created by IOS on 2023/7/17.
//

#import "BRODListView.h"

@implementation BRODListView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setNumLine:(NSInteger)numLine {
    _numLine = numLine;
    
    self.textL.numberOfLines = numLine;
    CGFloat left = numLine != 1 ? (kScreenWidth / 2.0 - 34) : 0;
    
    
    [self.textL mas_updateConstraints:^(MASConstraintMaker *make) {
       
        make.left.offset(left);
    }];
    
    [self.titleL mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        if (numLine != 1) {
            make.top.equalTo(self.textL.mas_top).offset(2);
        }else {
            make.centerY.offset(0);
        }
    }];
}

#pragma mark - UI --
- (void)setUI {
    
    [self addSubview:self.titleL];
    [self addSubview:self.textL];
    
    
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.centerY.offset(0);
    }];
    [self.textL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-20);
        make.left.offset(0);
        make.top.offset(14);
        make.bottom.offset(-14);
    }];
    
    UIView *line = [BRToolsView getLineView:UIColorMakeWithHex(@"#D2D8E2")];
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.offset(0);
        make.left.offset(20);
        make.height.mas_equalTo(0.5);
    }];
    _line = line;
}

- (QMUILabel *)titleL {
    
    if (_titleL == nil) {
        _titleL = [BRToolsView br_label:@"--" textColor:kColorTitle66B font:[UIFont fontM:13]];
    }
    return _titleL;
}

- (QMUILabel *)textL {
    if (_textL == nil) {
        _textL = [BRToolsView br_label:@"--" textColor:kColorTitle font:[UIFont fontS:15]];
        _textL.textAlignment = NSTextAlignmentRight;
    }
    return _textL;
}


@end


@implementation BRODListImgView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

#pragma mark - UI --
- (void)setUI {
    [super setUI];
    
    [self.titleL mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.offset(40);
    }];
    
    [self addSubview:self.leftImg];
    [self.leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(14);
        make.centerY.offset(0);
        make.left.offset(20);
    }];
}

- (UIImageView *)leftImg {
    
    if (_leftImg == nil) {
        _leftImg = [[UIImageView alloc] initWithImage:UIImageMake(@"order_coupon")];
    }
    return _leftImg;
}

@end
